import unittest
from time import sleep
from tools.utils import chrome
from tools.cookie import cookie_get


class BaseCase(unittest.TestCase):
    @classmethod
    def setUpClass(self) -> None:
        self.ck = cookie_get()

    def setUp(self) -> None:
        self.driver = chrome()
        self.driver.get('http://192.168.1.25')
        self.driver.add_cookie(self.ck)
        self.driver.get("http://192.168.1.25/crm/index.php")




    def tearDown(self) -> None:
        sleep(5)
        self.driver.quit()


    def assertAlertExist(self):
        try:
            self.driver.switch_to.alert.text
        except Exception:
            raise AssertionError("弹窗不存在")

    def assertAlertNotExist(self):
        try:
            self.driver.switch_to.alert.text
        except Exception:
            pass
        else:
            raise AssertionError("弹窗存在")

